import request from '@/utils/request'
import Qs from 'qs'

const api_name = '/system/user'

export default {
  getUserList(pageNum, pageSize, searchName) {
    let data = {
      'pageNum': pageNum,
      'pageSize': pageSize,
      'searchName': searchName
    }
    return request({
      url: `${api_name}/list`,
      method: 'post',
      data: Qs.stringify(data)
      // headers: {
      //   'Content-Type': 'application/x-www-form-urlencoded'
      // }
    })
  },

  addUser(user) {
    let data = {
      'account': user.account,
      'nickname': user.nickname,
      'password': user.password,
      'mobile': user.mobile
    }
    return request({
      url: `${api_name}/save`,
      method: 'post',
      data: Qs.stringify(data)
    })
  },

  // 根据id查询
  findById(id) {
    let data = {
      'id': id
    }
    return request({
      url: `${api_name}/detail`,
      method: 'post',
      data: Qs.stringify(data)
    })
  },

  updateUser(user) {
    let data = {
      'id': user.id,
      'account': user.account,
      'nickname': user.nickname,
      'password': user.password,
      'mobile': user.mobile
    }
    return request({
      url: `${api_name}/update`,
      method: 'post',
      data: Qs.stringify(data)
    })
  },

  deleteById(id){
    let data = {
      'id': id
    }
    return request({
      url: `${api_name}/isStatus`,
      method: 'post',
      data: Qs.stringify(data)
    })
  },

  getUserPassWord(){
    return request({
      url: `${api_name}/getUserPassWord`,
      method: 'post',
    })
  },

  updateUserPwd(oldPassword,newPassword){
    return request({
      url: `${api_name}/getUserPassWord`,
      method: 'post',
    })
  }

}
